#include "btree.h"
#include "Queue.h"


void testFind(BTNode* root)
{
	printf("--------testFind--------\n");
	BTNode* ret = BinaryTreeFind(root, 'a');
	if (NULL == ret)
		printf("Find: a=%p\n", ret);
	else
		printf("Find: a=%p\t%c\n", ret, ret->_data);
	//
	ret = BinaryTreeFind(root, 'A');
	if (NULL == ret)
		printf("Find: A=%p\n", ret);
	else
		printf("Find: A=%p\t%c\n", ret, ret->_data);

	ret = BinaryTreeFind(root, 'E');
	if (NULL == ret)
		printf("Find: E=%p\n", ret);
	else
		printf("Find: E=%p\t%c\n", ret, ret->_data);

	ret = BinaryTreeFind(root, 'G');
	if (NULL == ret)
		printf("Find: G=%p\n", ret);
	else
		printf("Find: G=%p\t%c\n", ret, ret->_data);
	printf("--------testFind--------\n");

}

void testKSize(BTNode* root)
{
	printf("\n--------testKSize--------\n");
	printf("1: %d\n", BinaryTreeLevelKSize(root, 1));
	printf("2: %d\n", BinaryTreeLevelKSize(root, 2));
	printf("3: %d\n", BinaryTreeLevelKSize(root, 3));
	printf("4: %d\n", BinaryTreeLevelKSize(root, 4));
	printf("5: %d\n", BinaryTreeLevelKSize(root, 5));
	printf("6: %d\n", BinaryTreeLevelKSize(root, 6));
	printf("--------testKSize--------\n");
}

void testBinaryTreeLevelOrder(BTNode* bt)
{
	printf("\n--------LevelOrder--------\n");
	BinaryTreeLevelOrder(bt);
	printf("\n--------LevelOrder--------\n");

}

testTreeComplete()
{
	char c[] = "ABD##E#H##CF##G##";
	int i = 0;
	BTNode* root = BinaryTreeCreate(c, (int)strlen(c), &i);
	printf("%s isComplete: %d\n", c, BinaryTreeComplete(root));
	BinaryTreeDestory(&root);

	char d[] = "ABDS###C##EF##G##";
	i = 0;
	BTNode* root2 = BinaryTreeCreate(d, (int)strlen(d), &i);
	printf("%s isComplete: %d\n", d, BinaryTreeComplete(root2));
	BinaryTreeDestory(&root2);
}

int main()
{
	char c[] = "ABD##E#H##CF##G##";
	int i = 0;
	BTNode* root = BinaryTreeCreate(c, (int)strlen(c), &i);
	BinaryTreePrevOrder(root);
	printf("\n");
	BinaryTreeInOrder(root);
	printf("\n");
	BinaryTreePostOrder(root);
	printf("\n");

	printf("Size: %d\n", BinaryTreeSize(root));
	printf("LeafSize: %d\n", BinaryTreeLeafSize(root));

	testFind(root);
	testKSize(root);

	testBinaryTreeLevelOrder(root);

	testTreeComplete();

	BinaryTreeDestory(&root);
	return 0;
}